package model

import (
	"fmt"
	"time"
	"turingApi/conf"
)

// SysSettings SignLogs用户
type SysSettings struct {
	Id      int       `xorm:"INT(11) PK AUTOINCR comment('主键')" json:"id"` //主键
	Key     string    `xorm:"VARCHAR(64) UNIQUE comment('key')" json:"key"`
	Value   string    `xorm:"VARCHAR(200) comment('value')" json:"value"`
	Created time.Time `xorm:"DATETIME INDEX" json:"created"`
	Updated time.Time `xorm:"DATETIME" json:"updated"`
}

func (SysSettings) TableName() string {
	return "sys_settings"
}

// GetSetting SignGet 单条用户信息
func GetSetting(key string) (*SysSettings, bool) {
	mod := &SysSettings{}
	has, err := db.Where("`key` = ?", key).Get(mod)
	if err != nil {
		conf.Logger.Error(fmt.Sprintf("Error occurred while querying: %v", err))
	}
	return mod, has
}
